﻿Configuration MyTestSubversion2
 {
    Import-DscResource -ModuleName cSourceControl
     # A Configuration block can have zero or more Node blocks
     Node "SRVESF001"
     {
         # Resource Block

         # File is a built-in resource you can use to manage files and directories
         # This example ensures files from the source directory are present in the destination directory
         cSubversionSynchronization NotCan
         {
             Ensure = "Present"  # You can also set Ensure to "Absent"
             Url = "https://mesf.svn.codeplex.com/svn/Main/ApplicationServices" # Default is "File" but this tells it to look at entire folder
             Path = "D:\Temp\ApplicationServices2" # This is a path that has source files
         }

     }
 }


Configuration DeployTalendInfraStructure
 {
    param(
        # Name of Switch to create
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [String]$DefaultFolder,

        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [Object[]]$TalendProjects
    )
    
    Import-DscResource -ModuleName cSourceControl
    Import-DscResource -ModuleName cFileShare

     # A Configuration block can have zero or more Node blocks
     Node $AllNodes.NodeName
     {

        Script TalendRootCreation
        {
            SetScript = ({New-Item -Path {0} -ItemType directory}  -f $DefaultFolder)
            TestScript = ({ Test-Path -Path {0} -PathType Container } -f $DefaultFolder)
            GetScript = { <# This must return a hash table #> } 
        }

        cCreateFileShare CreateShare
        {
            ShareName = "TESTYGO"
            Path      = $DefaultFolder
            Ensure    = 'Present'
            DependsOn = "[Script]TalendRootCreation"
        }

         # Resource Block

         # File is a built-in resource you can use to manage files and directories
         # This example ensures files from the source directory are present in the destination directory

         foreach($TalendProject in $TalendProjects)
         {

             cSubversionSynchronization "Talend_$($TalendProject.Name)"
             {
                 Ensure = "Present"  # You can also set Ensure to "Absent"
                 Url = $TalendProject.dev # Default is "File" but this tells it to look at entire folder
                 Path = $(Join-Path $DefaultFolder -ChildPath $TalendProject.name)  # This is a path that has source files
             }
         }



     }
 }





Configuration MyTestFileConfig
 {
     # A Configuration block can have zero or more Node blocks
     Node "SRVESF001"
     {
         # Resource Block

         # File is a built-in resource you can use to manage files and directories
         # This example ensures files from the source directory are present in the destination directory
         File MyFileExample
         {
             Ensure = "Present"  # You can also set Ensure to "Absent"
             Type = "Directory" # Default is "File" but this tells it to look at entire folder
             Recurse = $true # Check all subfolders and content
             MatchSource = $true # Check for new files as part of the source
             SourcePath = "D:\Temp\FromSources" # This is a path that has source files
             DestinationPath = "D:\Temp\ToSources" # The path where we want to ensure the files are present
         }

     }
 }
 
 
 Configuration MyTestFileConfig2
 {
     # A Configuration block can have zero or more Node blocks
     Node "SRVESF001"
     {
         # Resource Block

         # File is a built-in resource you can use to manage files and directories
         # This example ensures files from the source directory are present in the destination directory
         File MyFileExample
         {
             Ensure = "Present"  # You can also set Ensure to "Absent"
             Type = "Directory" # Default is "File" but this tells it to look at entire folder
             Recurse = $true # Check all subfolders and content
             MatchSource = $true # Check for new files as part of the source
             SourcePath = "D:\Temp\FromSources" # This is a path that has source files
             DestinationPath = "D:\Temp\ToSources_ygo" # The path where we want to ensure the files are present
         }

     }
 }


 ###
### find the Process that is hosting the DSC engine
###
#$dscProcessID = Get-WmiObject msft_providers | Where-Object {$_.provider -like 'dsccore'} | Select-Object -ExpandProperty HostProcessIdentifier 

###
### Kill it
###
#Get-Process -Id $dscProcessID | Stop-Process
